<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>精选板块轮动</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">						
			#towriter{
				margin-top:-15px;
				border: 1px solid #555555;
				height:100%;	
			}			
			.fixedBox{
				border:none;
				white-space: nowrap;								
			}
			.fixedBox::-webkit-scrollbar {
				width: 12px;     
				height: 12px;				
			}			
			p {margin-top:0px;margin-bottom:5px}				
			
			table{
				width:80px; 
				border-collapse:collapse; 
				text-align:center;
			}
			td,th{border:1px solid #696969}
			th { 
				color:#E5E5E5;  <!-- 表头文字颜色 -->
			}
			td a:link{
				color:#E5E5E5;  <!-- 列表文字颜色 -->
			}	
			
			#bar, #bar1{
				padding-top: 1px;
				height: 25px;								
				background-color: #666;
				<!-- cursor: move; -->
			}			
			
			#content, #content1{				
				height: 450px;
				background-color: #000;  <!-- 弹出框背景色 -->
				white-space: nowrap;
				overflow:auto;				
			}
			
			#content::-webkit-scrollbar, #content1::-webkit-scrollbar{
				width: 12px;     
				height: 12px;
				scrollbar-arrow-color:white;
				background-color: #E5E5E5;		
			}
			#content::-webkit-scrollbar-thumb, #content1::-webkit-scrollbar-thumb{
				border-radius: 5px;
				-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
				background: rgba(0,0,0,0.2);
				scrollbar-arrow-color:#555;
			}
			#content::-webkit-scrollbar-track, #content1::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
				border-radius: 0;
				background: rgba(0,0,0,0.1);
			}			
		</style>
	</head>
	<body>				
		<div id="towriter" class="fixedBox">
			<div id="towritea" class="fixedBox" style="position:relative; float:left; left:0px; width:1400px;">
				<div id="title" style="margin:10px 50px -5px 5px;"></div>
				<div id="towrite" style="float:left;margin-left:20px;">
					<div id="bar"></div>
					<div id="content" ></div>
				</div>
				<div style="float:left;">
					<div id="towrites"></div>									
					<div id="canvasBox" style="float:left;">
						<canvas id="charts1" style="float:left;;margin-top:-20px;"></canvas>
						<canvas id="charts2" style="float:left;width:950px;margin-top:-30px;"></canvas>				
					</div>
				</div>
				<div id="towritelb" style="float:left;margin-left:20px;">
					<div id="bar1"></div>
					<div id="content1" ></div>
				</div>
				<div style="float:left;">
					<div id="towritets" style="margin-left:5px;"></div>									
					<div id="canvasBox1" style="float:left;margin-top:-12px;">					
						<canvas id="charts3" style="float:left;;margin-top:-20px;"></canvas>								
					</div>
				</div>
				
			</div>
		</div>	
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script> 
		<script>
			var z = 1;   //最高板（1、显示三板及以上；0、只显示最高板）
			var bkcolor = $("body").css("backgroundColor");
			var thcolor = "";
			var tdcolor = "";
			var cbkcolor = $("#content").css("backgroundColor");		
			var day = new Date();
			var dt = "";  //当日
			var tt = "";
			var tt1 = "";
			var k = 0;			
			window.onload = function() {
				dt = day.Format("yyyy-MM-dd");			
				getSource();
				changeStyle();								
			}
			
			var ztssx = 0;				
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					day = new Date();
					ztssx++;					
					if(ztssx == 5){ //定时刷新涨停数
						ztssx = 0;
						ztemp = "";	
					}		
					getSource();					
					const interval = setInterval(function(){
						if(rid != "" && y == 1){
							changeCss(rid,qid);
							clearInterval(interval);
						}					
					},100);					
					
					if(sx == 1){
						showInform(ztgp);					
					}
					
					if(lbt == dt){
						setTimeout(function(){lbtt()}, 100); 				
					}
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
					if(k == 0){		//最后交易日才刷新		
						time_range("9:00","15:15")	
					}							
				},
				60000);
			})
			
			window.onresize = function() {
				var obj = document.getElementById("towriter");				
				obj.style.left= "0px"; 				
				obj.style.width= document.documentElement.clientWidth + "px";						
			}
			
			function changeStyle() {
				var obj = document.getElementById("towriter");				
				obj.style.left= "0px"; 				
				obj.style.width= document.documentElement.clientWidth + "px";				
				
				var div = document.getElementById("towrites");
				for (i = 1; i < 11; i++){
					var obj = document.createElement("div");
					obj.id = "towrite" + i;
					obj.className = "fixedBox";
					obj.style.position= "relative"; 
					obj.style.float= "left"; 
					obj.style.left= "0px"; 				
					obj.style.width= "82px";
					obj.style.height= "260px";					
					obj.style.fontSize="12px";	
					div.appendChild(obj);					
				}
				
				var obja = document.getElementById("towrite");  //个股行情窗口
				obja.style.left= "0px"; 				
				obja.style.width= "375px";							
				obja.style.fontSize="12px";		
					
				var obj1 = document.getElementById("canvasBox");				
				obj1.style.left= "0px"; 				
				obj1.style.width= "950px";
				obj1.style.height= "260px";
				
				var obj2 = document.getElementById("charts1");				
				obj2.style.left= "0px"; 				
				//obj2.style.width= "900px";				
				
				var obj3 = document.getElementById("charts2");				
				obj3.style.left= "0px"; 				
				//obj3.style.width= "900px";				
				
				var div = document.getElementById("towritets");
				for (i = 1; i < 11; i++){
					var obj = document.createElement("div");
					obj.id = "towritet" + i;
					obj.className = "fixedBox";
					obj.style.position= "relative"; 
					obj.style.float= "left"; 
					obj.style.left= "0px"; 				
					obj.style.width= "82px";
					//obj.style.height= "60px";					
					obj.style.fontSize= "12px";
					//obj.style.border= "1px solid #696969";
					//obj.style.whiteSpace="normal";					
					div.appendChild(obj);					
				}
				
				var objb1 = document.getElementById("canvasBox1");				
				objb1.style.left= "0px"; 				
				objb1.style.width= "900px";
				
				
				var objb2 = document.getElementById("charts3");				
				objb2.style.left= "0px"; 
				
				var objb3 = document.getElementById("towritelb");  //连板行情窗口
				objb3.style.top= div.style.top; 	
				objb3.style.left= "0px"; 				
				objb3.style.width= "375px";							
				objb3.style.fontSize="12px"
			}					
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};			
			
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function BookingRmk(date){         				
				tt1 = date;						
				k = 0;
				a = 0;  //切换日期，清零
				if(dt != tt1){			
					k = 1;								
				}
				tz = "";
				dmz = ""; 
				getSource();
			}
			
			var y = 0;
			var bjs = "";
			function getSource() {
				y = 0;
				var div = document.getElementById("title");
				var qh = "<a style='position:absolute; left:700px;' href='javascript:void(0)' onclick='clearstorage()'>" + "清除缓存" + "</a>";
				var hc = "<a style='position:absolute; left:600px;' href='javascript:void(0)' onclick='qbhc()'>" + "缓存全部" + "</a>";
				var ds = "<span id='ds' style='position:absolute; left:30px; margin-top:5px;'>" + bjs + "<span>";
				div.innerHTML = '<font color=#FF8C00; size="3" style="margin-left:300px;">精选板块轮动<font size="1">&nbsp;&nbsp;&nbsp;&nbsp;' + qh + hc + ds + '</font></font><input style="width: 90px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';		
				
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=15&apiv=w21&Type=1&c=ZhiShuRanking&ZSType=7"; 
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=15&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt1; 			
				var url = url1;
				if(k == "1"){
					url = url2;
				}								
				if (window.XMLHttpRequest) {
					xmlHttp1 = new XMLHttpRequest();								
				} else {
					xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");								
				}				
				xmlHttp1.onreadystatechange = writeSource1;
				xmlHttp1.open("GET", url, true);
				xmlHttp1.send(null);				
			}
			
			var rqs = ""; //判断交易日用(缓存)
			var tz = "";  //折线图用 rq
			var dmz = "";  //折线图用 dm
			var a = 0; 
			var b = 0;
			function writeSource1() { 
				if (xmlHttp1.readyState == 4) { 
					var div = document.getElementById('towrite1');																
					var data = xmlHttp1.responseText
					
					if(k == 0){											
						//tt1 = data.match(/\"Day\":\[\"(\S*)\"\],/)[1];	
						tt1 = data.match(/"Day":\["(\S*)/)[1].split('"]')[0];
						if(dt != tt1){			
							k = 1;								
						}
						day = new Date(tt1);
						rqs = tt1 + ";";  //判断交易日用						
					}else{
						day = new Date(tt1);
						day.setTime(day.getTime());				
						for (i = 1; i < 100; i++){
							if(i > 1){
								day.setTime(day.getTime() - 24*60*60*1000);							
							}
							tt1 = day.Format("yyyy-MM-dd");							
							var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt1; 					
							var xhr = new XMLHttpRequest();	
							xhr.open("GET", url, false);//同步 
							xhr.send(null)																										
							var data = xhr.responseText;					
							if(data.indexOf("MYSQL数据库链接出错!") == -1){
								break;
							}
						}
					}
					//alert(tt1);	
					div.innerHTML = "<span style='color:#FFFF00'>" + tt1 + "</span>";					
					document.getElementById("PriceDate").value = tt1;	
					if(data.indexOf("MYSQL数据库链接出错!") == -1)	{
						data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
						data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
						str = word.match(/\[(\S*)/)[1]; 
						var dm = str.split(',')[0].replace(/"/g,"");
						var name = str.split(',')[1].replace(/"/g,"");										
						return '{"code":' + str.split(',')[0] + 
						',"name":"' + name + '"' +
						',"qd":' + str.split(',')[2] + 
						',"zf":' + keepTwoDecimal(str.split(',')[3]);
						});						
						data = data.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");
						data = data.match(/list\":(\S*)/)[1] ;
						//document.write(data);
						Ctable(tt1,data,"towrite1");
						if(dt == tt1){
							setTimeout(function(){lastday()}, 100);  //延时执行
						}	
					}
					y = 1;					
					thcolor = $("th").css("color");				
					tdcolor = $("td a:first").css("color");		
									
					if(k == 0){					
						if(dt == tt1 && b == 0){ //竞价后切换
							a = 0;
							b++;
						}
						a++;
						//alert(a)
						if(a == 1){  //刷新或竞价后执行一次							
							gethis(); //交易日推算
						}
					}else{
						gethis();						
					}
					
					setTimeout(function(){lbtt()}, 200);  //延时执行
				}				
			}
			
			function qbhc(){  //全部缓存
				//alert(dmz)				
				var ss = dmz.split(";");
				var n = 0;
				$("#ds").text('开始缓存……');
				setTimeout(loop, 100);
				function loop(){										
					var dm = ss[n];
					if(dm != ""){					
						$("#ds").text("正在缓存：" + dm + "（剩余：" + (ss.length - n) + "只）");						
						//hczts(dm);
						setTimeout(function(){hczts(dm)}, 200);
					}					
					n++;
					if( n < ss.length){
						setTimeout(loop, 50);
					}else{
						$("#ds").text("完成");
						setTimeout(function(){$("#ds").text("")}, 1000);
					}					
				};							
			}			
			
			function hczts(dm){  //缓存历史涨停数、连板数数据						
				var ts = tz.split(";");									
				for (i = 10; i >= 0; i--){
					tt = ts[i];					
					if(k == 0 && i == 0){  //不计算最新交易日
						tt = "";
					}
					
					if(tt != ""){					
						var p = 0;
						var zt = "";	
						var lb = "";							
						var ztshc = dm + "-zts-" + tt.replace(/-/g,""); //涨停数缓存
						var lbshc = dm + "-lbs-" + tt.replace(/-/g,"");  //连板数缓存
						var dcs = getdczts(tt);	//东财涨停数据
						if(dcs == ""){						
							dcs = getkplzts(tt); //KPL涨停数据	
						}	
						if(localStorage.getItem(ztshc) == null || localStorage.getItem(lbshc) == null){							
							var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=100&c=ZhiShuRanking&old=1&Type=20&PlateID=" + dm + "&Date=" + tt;;																		
							var xhr = new XMLHttpRequest();	
							xhr.open("GET", url, false);//同步 
							xhr.send(null)																										
							var data = xhr.responseText;						
							var result = 0;
							var c = 0;
							data = data.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';
							
							var ss = data.split('],[');				
							for (j = 0; j < ss.length; j++){											
								
								var f = ss[j].split(',');
								var code = f[0].replace(/"/g,'').replace('[[','');
								var name = UnUnicode(f[1]).replace(/"/g,'');
								if(name.indexOf('ST') == -1){  //过滤ST
									var b = 0;									
									if(f[28] > 0){							
										result++;  //涨停数										
										if(dcs.indexOf(code) > -1){  //先调用DC数据
											dcs = dcs.replace(/"/g,'');
											b = dcs.split(code)[1].split('lbc:')[1].split('}')[0];											
										}else{
											//alert(tt + " " + code + " " + name)
											b = UnUnicode(f[23]);								
											b = b.replace(/"/g,'').replace("连板","").replace("首板","1").replace("新上市未开板","1");
											if(b.indexOf("天") > -1){
												b = 1;
											}else if(b.indexOf("昨") > -1){
												b = 0;
											}
										}
										if(b > c){
											c = b;   //连板数
										}
									}else{										
										zt = '["' + tt + '",' + result + "]"																													
										lb = '["' + tt + '",' + c + "]"																			
										localStorage.setItem(ztshc, zt);  //写入缓存
										localStorage.setItem(lbshc, lb);  //写入缓存										
										break;
									}
								}
							}
						}	
					}					
				}					
			}
			
			function bkzts(ss){  //显示折线图						
				var dm = ss.split("#")[0];
				var mc = ss.split("#")[1];
				var zts = "";
				var lbs = "";								
				//alert(tz)
				var d = 1; //判断有无东财数据
				var ts = tz.split(";");				
				//for (i = 10; i >= 0; i--){
				var i = 0;				
				(function loop() {					
					$("#ds").text(dm + ' ' + mc + ' 请稍等(' + (10 - i) + ')');
					tt = ts[i];										
					if(tt != ""){
						//alert(tt)					
						var p = 0;						
						var zt = "";	
						var lb = "";							
						var ztshc = dm + "-zts-" + tt.replace(/-/g,""); //涨停数缓存
						var lbshc = dm + "-lbs-" + tt.replace(/-/g,"");  //连板数缓存
						
						var dcs = getdczts(tt);	//东财涨停数据
						if(dcs == ""){						
							dcs = getkplzts(tt); //KPL涨停数据	
						}	
						if(dcs != ""){
							if(k == 0 && i == 0){  //最新交易日
								p = 1
							}else{
								if(localStorage.getItem(ztshc) != null){  
									zt = localStorage.getItem(ztshc);								
									zts += zt + ",";
									//alert(zts)
								}else{
									p = 1;
								}	
								
								if(localStorage.getItem(lbshc) != null) {  
									lb = localStorage.getItem(lbshc);
									//alert(lb)
									lbs += lb + ",";
									//alert(lbs)
								}else{
									p = 1;
								}
							}
										
							if(p == 1){							
								var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&st=100&a=ZhiShuStockList_W8&c=ZhiShuRanking&old=1&Type=20&PlateID=" + dm; 										
								var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=100&c=ZhiShuRanking&old=1&Type=20&PlateID=" + dm + "&Date=" + tt;;
								var url = url2;
								if(i == 0){
									url = url1;
								}
									
								var xhr = new XMLHttpRequest();	
								xhr.open("GET", url, false);//同步 
								xhr.send(null)																										
								var data = xhr.responseText;						
								var result = 0;
								var c = 0;
								data = data.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';
								//document.write(data);
								
								var ss = data.split('],[');				
								for (j = 0; j < ss.length; j++){																			
									var f = ss[j].split(',');
									var code = f[0].replace(/"/g,'').replace('[[','');
									var name = UnUnicode(f[1]).replace(/"/g,'');
									if(name.indexOf('ST') == -1){  //过滤ST
										var b = 0;
										
										if(f[28] > 0){							
											result++;  //涨停数
											
											if(dcs.indexOf(code) > -1){  //先调用DC数据
												//alert(tt + " " + code + " " + name)
												dcs = dcs.replace(/"/g,'');
												b = dcs.split(code)[1].split('lbc:')[1].split('}')[0];
												//alert(b)
											}else{
												//alert(tt + " " + code + " " + name)
												b = UnUnicode(f[23]);								
												b = b.replace(/"/g,'').replace("连板","").replace("首板","1").replace("新上市未开板","1");
												if(b.indexOf("天") > -1){
													b = 1;
												}else if(b.indexOf("昨") > -1){
													b = 0;
												}
											}
											if(b > c){
												c = b;   //连板数
											}
										}else{
											//alert(result)
											zt = '["' + tt + '",' + result + "]"									
											zts += zt + ",";
											
											lb = '["' + tt + '",' + c + "]"									
											lbs += lb + ","
											
											if(k == 1 || (k == 0 && i != 0)){ //非最新交易日
												localStorage.setItem(ztshc, zt);  //写入缓存
												localStorage.setItem(lbshc, lb);  //写入缓存
											}
											break;
										}
									}
								}
							}						
						}else{
							d = 0;
						}
					}
					i++
					if( i <= 10){
						setTimeout(loop, 50);
					}else{
						if(d == 1){
							bjs = dm + ' ' + mc;
							$("#ds").text(bjs);							
							zts = "[" + zts + "]";
							zts = zts.replace("],]","]]");				
							//alert(zts); 
							var json1 = JSON.parse(zts);
							
							lbs = "[" + lbs + "]";
							lbs = lbs.replace("],]","]]");	
							//alert(lbs);
							var json2 = JSON.parse(lbs);
							
							//$("#chartst").text(dm + ' ' + mc);						
							goChart(json1,"charts1","涨停数量");
							goChart(json2,"charts2","连板高度");
						}else{
							$("#ds").text('数据不全，请稍后再试');
							//setTimeout(function(){$("#ds").text("")}, 1000);
						}
					}
					
				})();								
			}
			
			function getzts(tt, dm){  //获取涨停数
				var zt = "";								
				var ztshc = dm + "-zts-" + tt.replace(/-/g,""); //涨停数缓存											
				if(localStorage.getItem(ztshc) != null){  
					zt = localStorage.getItem(ztshc);
					zt = zt.replace(/"/g,"").split(tt + ',')[1].split(']')[0];
				}				
				return zt;
			}
			
			var ztemp = "";
			var dmx = "";  //最后交易日 板块代码
			function lastday(){	  //最后交易日 计算涨停数
				//alert(dmx);
				var aa = dmx.split(";");
				for (i = 0; i < 10; i++){
					var zt = "";
					var dm = aa[i];					
					var div = document.getElementById(dt + dm);					
					if(ztemp.indexOf(dm + '=') > -1){
						zt = ztemp.split(dm + '=')[1].split(',')[0];						
						div.innerHTML += "(" + zt + ")";
						//alert(1+"|"+zt)
					}else{	
						var url = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&st=100&a=ZhiShuStockList_W8&c=ZhiShuRanking&old=1&Type=20&PlateID=" + dm; 															
						var xhr = new XMLHttpRequest();	
						xhr.open("GET", url, false);//同步 
						xhr.send(null)																										
						var data = xhr.responseText;						
						var result = 0;						
						data = data.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';
						
						var ss = data.split('],[');				
						for (j = 0; j < ss.length; j++){																			
							var f = ss[j].split(',');
							if(f[28] > 0){							
								result++;  //涨停数							
							}else{							
								zt = result;
								ztemp += dm + '=' + zt + ',';
								break;
							}						
						}
						//alert(2+"|"+zt)
						div.innerHTML += "(" + zt + ")";
					}
				}
				dmx = "";
			}
			
			function UnUnicode(str) {
				return unescape(str.replace(/\\/g, "%"));
			}

			var datahis = "";
			function gethis() {			
				if(localStorage.getItem('bkldzrq') != null) {  //判断有无缓存日期
					var t = localStorage.getItem('bkldzrq'); //取缓存日期
					//alert(t)
					if(t.split(";")[0] != tt1){  //如果缓存首日不等于最后交易日，重新计算					
						for (j = 1; j < 10; j++){															
							gethisdata();							
							var div = document.getElementById("towrite" + (j + 1));	
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
							Ctable(tt,datahis,"towrite" + (j + 1));							
						}
						if(k == 0){					
							localStorage.setItem('bkldzrq', rqs);  //交易日期写入缓存
						}
					}else{  //否则取缓存数据
						for (i = 1; i < 10; i++){
							var div = document.getElementById("towrite" + (i + 1));
							tt = t.split(";")[i];							
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";
							datahis = localStorage.getItem('bkldz' + tt);
							Ctable(tt,datahis,"towrite" + (i + 1));								
						}				
					}				
				}else{   //首次
					for (j = 1; j < 10; j++){										
						gethisdata();						
						var div = document.getElementById("towrite" + (j + 1));	
						div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
						Ctable(tt,datahis,"towrite" + (j + 1));						
					}							
					localStorage.setItem('bkldzrq', rqs);  //交易日期写入缓存					
				}								
			}
									
			function gethisdata() {				
				day.setTime(day.getTime());				
				for (i = 1; i < 100; i++){	//节假日																										
					day.setTime(day.getTime() - 24*60*60*1000);
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt; 					
					var xhr = new XMLHttpRequest();	
					xhr.open("GET", url, false);//同步 
					xhr.send(null)																										
					var data = xhr.responseText;					
					if(data.indexOf("MYSQL数据库链接出错!") == -1){
						//alert(tt);
						rqs += tt + ";"
						
						if(localStorage.getItem('bkldz' + tt) != null) {   //判断有无缓存数据														
							datahis = localStorage.getItem('bkldz' + tt);    //取缓存数据							
						}else{							
							data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
							//data = data.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"qd":'+str.split(',')[2]+',"zf":'+keepTwoDecimal(str.split(',')[3]);});						
							data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
							str = word.match(/\[(\S*)/)[1]; 
							var dm = str.split(',')[0].replace(/"/g,"");
							var name = str.split(',')[1].replace(/"/g,""); 							
							return '{"code":' + str.split(',')[0] + 
							',"name":"' + name + '"' +
							',"qd":' + str.split(',')[2] + 
							',"zf":' + keepTwoDecimal(str.split(',')[3]);
							});		
							data = data.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");
							data = data.match(/list\":(\S*)/)[1] ;
							//document.write(data);
							datahis = data;
							localStorage.setItem('bkldz' + tt, datahis);  //历史单日数据写入缓存
						}																	
						break;											
					}
				}				
			}
			
			function getdczts(tt) {	//东财涨停数据				
				var data = "";
				if(localStorage.getItem('dczts' + tt) != null) {   //判断有无缓存数据														
					data = localStorage.getItem('dczts' + tt);    //取缓存数据							
				}else{	
					url = "http://push2ex.eastmoney.com/getTopicZTPool?cb=callbackdata1207668&ut=7eea3edcaed734bea9cbfc24409ed989&dpt=wz.ztzt&Pageindex=0&pagesize=1000&sort=lbc%3Adesc&date=" + tt.replace(/-/g,""); 					
					var xhr = new XMLHttpRequest();	
					xhr.open("GET", url, false);//同步 
					xhr.send(null)																										
					data = xhr.responseText;
					//document.write(data);
					//alert(dt)
					if(data.indexOf('"data":null') == -1){
						data = data.replace(/ /g,"").match(/\"pool\":(\S*)\}\}\);/)[1];
						//document.write(data);
						data = data.replace(/(\{\").*?(?=\})/g,function(word){ 				
							str = word.match(/\{(\S*)/)[1];	
							var lb = str.split(',')[9];					
							lb = lb.match(/"lbc":(\S*)/)[1];					
							return "{" + str.split(',')[0] + "," + str.split(',')[2] + "," + str.split(',')[9];							
						});
						data = data.replace(/}},{/g,"},{").replace(/}}]/g,"}]").replace(/}},/g,"");		
						//document.write(data);
						if(tt != dt){ //最新交易日不写入
							localStorage.setItem('dczts' + tt, data);  //历史单日数据写入缓存
						}
					}else{
						data = "";
					}
				}
				//alert(tt + data)
				return data;
			}
			
			function getkplzts(tt) {	//kpl涨停数据				
				var datas = "";
				if(localStorage.getItem('kplzts' + tt) != null) {   //判断有无缓存数据														
					datas = localStorage.getItem('kplzts' + tt);    //取缓存数据							
				}else{	
					for (i = 0; i < 5; i++){
						var p = 5 - i;								
						var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w21&Type=4&c=HomeDingPan&PidType=" + p;
						var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + p + "&Day=" + tt;				
						var url = url1;
						if(tt != dt){					
							url = url2;
						}
						
						xmlHttp = new XMLHttpRequest();
						xmlHttp.open("GET", url, false);  //同步方式
						xmlHttp.send(null);				
						
						var data = xmlHttp.responseText
						//document.write(data);
						
						data = data.replace("\[\[\]","\[\]");
						data = UnUnicode(data)
						if (data.indexOf('\"' + 'info' + '\"' + ':\[\]') == -1 ) { 
							data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';												
							data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
							str = word.match(/\[(\S*)/)[1];
							var lb = "";
							if(p == 5){
								var lbs = str.split(',')[18];							
								lb = ',"lbc":' + lbs;
								if(lbs.indexOf("天")>-1){
									lb = ',"lbc":"5"';
								}
							}else{
								lb = ',"lbc":"' + p + '"';
							}						
							return '{"code":' + str.split(',')[0] + 
							',"name":' + str.split(',')[1] + lb});
							
							data = data.replace(/\[\[\{/g,'[{').replace(/\]\]/g,"}]}").replace(/],{/g,"},{");														
							data = data.match(/\{\"info\":(\S*)\}\]\}/)[1] + "}]";
						}else{
							data = "";
						}
						datas += data;
					}
					datas = datas.replace(/}\]\[{/g,"},{").replace(/连板/g,"");	
					if(tt != dt){ //最新交易日不写入
						localStorage.setItem('kplzts' + tt, datas);  //历史单日数据写入缓存
					}
				}				
				return datas;				
			}
						
			function Ctable(tt,ss,id){
				if(tz.indexOf(tt) == -1){
					tz += tt + ";";
				}
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var n = 0;
				var b = 0;
				var h = 1;
				var gl = "强度";  //高亮				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('qd','强度');
					//key = key.replace('ZJJE','主力净额').replace('gang','主力').replace('plate','板块').replace('index','异动次数');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);
					if(gl == key.replace("%","")){
						n = m;
						th.style.color = "#FF6633";	
					}					
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				var zts = "";
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					var zts = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							if(dt != tt){
								zts = " (" + getzts(tt, dm) + ")";
							}
							tr.id = dm + id;
						}else if(p == 2){  //名称列
							mc = rc;
						}								
						if(p == 2 && zts != " ()"){
							td.innerHTML = "<a href='javascript:void(0)' style='float:left;' id='" + tt + dm + "' onclick='bkzts(\"" + dm + "#" + mc + "\");showInform(\"" + tt + "#" + dm + "#" + mc + "\");changeCss(\"" + dm + id + "\",\"" + id + "\")'>" + rc + zts + "</a>";						
						}else{
							td.innerHTML = "<a href='javascript:void(0)' style='float:left;'  onclick='bkzts(\"" + dm + "#" + mc + "\");showInform(\"" + tt + "#" + dm + "#" + mc + "\");changeCss(\"" + dm + id + "\",\"" + id + "\")'>" + rc + "</a>";
						}
						
						if(p == n + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";
						}																				
						tr.appendChild(td);							
						p++;
					}														
					if(mc.indexOf("ST") == -1 && h < 11){		//过滤ST	限制10行															
						if(dmz.indexOf(dm) == -1){
							dmz += dm + ";";
						}
						if(tt == dt){
							dmx += dm + ";";
						}	
						tbody.appendChild(tr);
						h++;
					}	
				}
				var div = document.getElementById(id);					
				div.appendChild(table);
				table.id = id;
				changeTable(table);		//隐藏某列	
				hover();				
			}
			
			//隐藏某列				
            function changeTable(table) {
                var trs = table.rows;
                for (var i = 0, len = trs.length; i < len; i++) {
                    var cell1 = trs[i].cells[0]; //隐藏第1列					
                    cell1.style.display = 'none';
					
					var cell2 = trs[i].cells[2]; 					
                    cell2.style.display = 'none';
					
					var cell3 = trs[i].cells[3]; 					
                    cell3.style.display = 'none';
                }
            }
			
			//方式1		
			var pid = "";
			function changeCss1(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
				
				//5组选中行id集合
				if(pid.indexOf(id) > -1){				
					var aa = "";				
					var ss = pid.split(";");
					for(i = 0; i < ss.length-1; i++){
						if(ss[i].indexOf(id) > -1){						
							aa += hid + ";";
						}else{
							aa += ss[i] + ";";
						}				
					}
					pid = aa;
				}else{
					pid += hid + ";";
				}
				
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			//方式2：相同行高亮
			var qid = "";
			var rid = "";
			function changeCss(hid,id){				
				qid = id;
				rid = hid;
				//alert(rid + "|" + qid)
				var tlist = document.getElementById("towriter").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
								
				pid = "";				
				var dm = hid.split("towrite")[0];				
				for(var i = 0; i < tlist.length; i++){
					var a = tlist[i].id;
					if(a.split("towrite")[0] == dm){
						//alert(a)
						tlist[i].style.backgroundColor = "#483D8B";
						pid += a + ";";
					}					
				}					
			}
			
			function changeCsss(hid,id){				
				qid = id;
				rid = hid;
				//alert(rid + "|" + qid)
				var tlist = document.getElementById("towriter").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
								
				pid = "";				
				var dm = hid.split("towrite")[0];				
				for(var i = 0; i < tlist.length; i++){
					var a = tlist[i].id;
					if(a.split("towrite")[0] == dm){
						//alert(a)
						tlist[i].style.backgroundColor = "#DDA0DD";
						pid += a + ";";
					}					
				}					
			}
			
			function hover(){  //鼠标经过			
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头							
							if(pid.indexOf(this.id) == -1){  //过滤选中行
								this.style.background = bkcolor;
							}else{
								this.style.background = "#483D8B";
							}
						}						
					}					
				}
			}
			
			var rqb = "";
			var bkb = "";			
			var ztgp = "";
			var sx = 0;
			function showInform(ss){
				//alert(ss)
				ztgp = ss;
				
				var dms = ss.split('#');
				var rq = dms[0];				
				if(rq == ""){
					rq = tt1;
				}
				var dm = dms[1];
				var bk = dms[2];
				
				var div = document.getElementById('bar');											
				var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
				var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
				var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
				div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";
				<!-- var bfyy = "<a style='margin-right:-5px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				 -->
				<!-- var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>' -->
				<!-- var forward = '<a href="javascript:forward(' + dm + ');"  style="margin-left:-10px;color:#fff">→</a>' -->
				<!-- div.innerHTML = "<b style='color:#FFFF00;'>" + rq + bfyy + '日期：' + back + forward + "</b>"; -->
				
				update(rq,dm);	
				rqb = rq;
				bkb = bk;
								
				if(rq == dt){
					sx = 1;
				}else{
					sx = 0;
				}
			}
			
			function back(dm) {						
				var rq = rqb;			
				//alert(rq)
				var ts = tz.split(";");					
				for (i = 10; i >= 0; i--){					
					if(rq == ts[i] && i > 0){						
						rq = ts[i-1];
						break;
					}
				}
				if(i > 0){
					rqb = rq;
					var div = document.getElementById('bar');											
					var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
					var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
					var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
					div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";					
					<!-- var bfyy = "<a style='margin-right:-5px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				 -->
					<!-- var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>' -->
					<!-- var forward = '<a href="javascript:forward(' + dm + ');"  style="margin-left:-10px;color:#fff">→</a>' -->
					<!-- div.innerHTML = "<b style='color:#FFFF00;'>" + rq + bfyy + '日期：' + back + forward + "</b>"; -->
					update(rq,dm);
				}
			}
			
			function forward(dm) {				
				var rq = rqb;							
				var ts = tz.split(";");								
				for (i = 0; i < ts.length; i++){				
					if(rq == ts[i] && i < ts.length-2){						
						rq = ts[i+1];
						break;
					}
				}				
				if(i < ts.length-2){
					rqb = rq;
					var div = document.getElementById('bar');											
					var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
					var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
					var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
					div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";										
					<!-- var bfyy = "<a style='margin-right:-5px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				 -->
					<!-- var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>' -->
					<!-- var forward = '<a href="javascript:forward(' + dm + ');"  style="margin-left:-10px;color:#fff">→</a>' -->
					<!-- div.innerHTML = "<b style='color:#FFFF00;'>" + rq + bfyy + '日期：' + back + forward + "</b>"; -->
					update(rq,dm);
				}
			}
			
			var Order = 1;
			var old = 1; 
			var dmb = "";
			function update(tt,dm) {				
				dmb = dm;	
				var url = "";
				if(k == 0 && tt == tt1){				
					url = "https://apphq.longhuvip.com/w1/api/index.php?Order=" + Order + "&st=100&a=ZhiShuStockList_W8&c=ZhiShuRanking&old=" + old + "&apiv=w21&Type=6&PlateID=" + dm; 												
				}else{
					url = "https://apphis.longhuvip.com/w1/api/index.php?st=100&Index=0&old=" + old + "&Order=" + Order + "&a=ZhiShuStockList_W8&apiv=w26&Type=6&c=ZhiShuRanking&PlateID=" + dm + "&Date=" + tt;												
				}
								
				if (window.XMLHttpRequest) {
					xmlHttp = new XMLHttpRequest();
				} else {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xmlHttp.onreadystatechange = writeSource;
				xmlHttp.open("GET", url, true);
				xmlHttp.send(null);
			}
			
			function writeSource() { 			
				if (xmlHttp.readyState == 4) { 				
					var data = xmlHttp.responseText	
					data = data.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';					
					data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zf":'+str.split(',')[6] +
					',"lz":'+str.split(',')[24] +
					',"zl":'+str.split(',')[2] +
					',"lb":'+str.split(',')[23] + 
					',"zt":'+str.split(',')[39];});
					
					data = data.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");	
					//document.write(data);
					
					var json = JSON.parse(data);
						
					//创建table					
					var table=document.createElement("table");										
					var thead=document.createElement("thead");
					table.appendChild(thead);					
					var tr=document.createElement("tr");
					thead.appendChild(tr);					
					
					var m = 0;
					var v = 0;
					var b = 0;
					var gl = "领涨";  //高亮
					if(rs == 2){
						gl = "涨幅";
					}
					for(var key in json[0]){  //表头													
						key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('zl','主力').replace('lz','领涨');
						key = key.replace('lb','连板').replace('zt','主题').replace('zs','涨速%');
						var th=document.createElement("th");						
						th.innerHTML=key;						
						tr.appendChild(th);					
						if(key == "领涨"){
							b = m;							
							th.style.color = "#FFA500";
							
						}else if(key == "主力" || key == "连板" || key == "主题"){
							th.style.color = "#FFA500";	
						}
						if(gl == key.replace("%","")){
							v = m;
							th.style.color = "#FF6633";	
						}
						m++;
					}
										
					var tbody=document.createElement("tbody");					
					table.appendChild(tbody);
					
					//遍历json
					for(var i = 0; i < json.length; i++){					
						var tr=document.createElement("tr");						
						var p = 1;	
						var dm = "";
						var mc = "";					
						for(var key in json[i]){ //行元素遍历					
							var td=document.createElement("td");							
							
							var rc = json[i][key];
							if(p == 1){  //代码列
								dm = rc;
								tr.id = dm;
							}					
							td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeTCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
								
							if(p >= b + 1){							
								td.getElementsByTagName("a")[0].style.color = "#FFA500";															
							}
							if(p == v + 1){							
								td.getElementsByTagName("a")[0].style.color = "#FF6633";
							}						
							tr.appendChild(td);
							p++;
						}						
						tbody.appendChild(tr);
					}	
					//var div = document.getElementById("inform");
					var div = document.getElementById("content");
					div.style.whiteSpace = "nowrap"; 
					div.style.fontSize="12px";
					div.scrollTop = 0; //回到顶部	
					div.innerHTML = "";					
					div.appendChild(table);
					table.id = "gg";					
					
					
					var table=div.getElementsByTagName("table")[0];
					makeSortable(table);			
					ihover();
					changeTable1(table);
				}
			}
			
			//隐藏某列				
            function changeTable1(table) {
                var trs = table.rows;
                for (var i = 0, len = trs.length; i < len; i++) {
                    var cell1 = trs[i].cells[0]; //隐藏第1列					
                    cell1.style.display = 'none';
					
					var cell2 = trs[i].cells[4]; 					
                    cell2.style.display = 'none';
					
					var cell3 = trs[i].cells[6]; 					
                    cell3.style.display = 'none';
                }
            }
			
			var trid = "";
			function changeTCss(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = cbkcolor; 					
				}
				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			function ihover(){  //鼠标经过
				var rows = document.getElementById("gg").getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background = cbkcolor;
							}else{
								this.style.background = "#483D8B";
							}
						}						
					}					
				}
			}	
			
			var pt = 0;
			var rs = 0
			function makeSortable(table) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
							//alert(n);	
							
							if(n == 2){
								rs = n;
								Order = (pt%2 == 0) ? "1" : "0";								
								old = 0; 
								update(rqb,dmb);
								pt++;
							}
							
							if(old == 0 && n != 2){
								rs = 0;
								Order = 1;
								old = 1; 								
								update(rqb,dmb);
							}
							
							showCol(n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("主力") != -1|| headtxt.indexOf("主题") != -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt.indexOf("连板") != -1){								
									val1 = val1.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val1.indexOf("天")>-1){
										val1 = val1.split("天")[0];
									}else if(val1.indexOf("昨")>-1){
										val1 = 0;
									}else if(val1 == ""){
										val1 = -2;
									}										
									val1 = parseFloat(val1);
								
									val2 = val2.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val2.indexOf("天")>-1){
										val2 = val2.split("天")[0];
									}else if(val2.indexOf("昨")>-1){
										val2 = 0;
									}else if(val2 == ""){
										val2 = -2;
									}									
									val2 = parseFloat(val2);
								}else if(headtxt.indexOf("领涨") != -1){
									val1 = val1.replace("龙十","龙一十").replace("破板","1000");
									val2 = val2.replace("龙十","龙一十").replace("破板","1000");
									if(val1 == ''){
										val1 = '1001';
									}
									if(val2 == ''){
										val2 = '1001';
									}
									if(val1.indexOf("龙") != -1){
										val1 = ChineseToNumber(val1.replace("龙",""));										
									}										
									if(val2.indexOf("龙") != -1){
										val2 = ChineseToNumber(val2.replace("龙",""));
										
									}
									//val2 = parseFloat(val2);									
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
								
							});
							if(flag){
								rows.reverse();								
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;							
						}
					}(i));
				}
			}
			
			function showCol(iCol){			
				var div = document.getElementById("content");
				var oTable = div.getElementsByTagName('table')[0];
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = thcolor;
						
						oTable.rows[i].cells[3].style.color = "#FFA500";						
						oTable.rows[i].cells[4].style.color = "#FFA500";
						oTable.rows[i].cells[5].style.color = "#FFA500";
						oTable.rows[i].cells[6].style.color = "#FFA500";						
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}

				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = tdcolor;
					if(otagsA[i].id >= 4){
						otagsA[i].style.color = "#FFA500";								
					}
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}								
			}
			
			var chnNumChar = {零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9};

			var chnNameValue = {
			  十:{value:10, secUnit:false},
			  百:{value:100, secUnit:false},
			  千:{value:1000, secUnit:false},
			  万:{value:10000, secUnit:true},
			  亿:{value:100000000, secUnit:true}
			}

			function ChineseToNumber(chnStr){
			  var rtn = 0;
			  var section = 0;
			  var number = 0;
			  var secUnit = false;
			  var str = chnStr.split('');

			  for(var i = 0; i < str.length; i++){
				var num = chnNumChar[str[i]];
				if(typeof num !== 'undefined'){
				  number = num;
				  if(i === str.length - 1){
					section += number;
				  }
				}else{
				  var unit = chnNameValue[str[i]].value;
				  secUnit = chnNameValue[str[i]].secUnit;
				  if(secUnit){
					section = (section + number) * unit;
					rtn += section;
					section = 0;
				  }else{
					section += (number * unit);
				  }
				  number = 0;
				}
			  }
			  return rtn + section;
			}
			
			function clearstorage(){				
				if(localStorage.getItem('bkldzrq') != null){						
					localStorage.removeItem('bkldzrq'); //清除缓存localStorage
				}
				
				var n = 1;
				while (n > 0)
				{	
					var p = 1;				
					var q = p;
					for (var i = 0; i < localStorage.length; i++) { 
						var key = localStorage.key(i);		 				
						if(key.indexOf('bkldz') > -1 || key.indexOf('-zts-') > -1 || key.indexOf('-lbs-') > -1 || key.indexOf('dczts') > -1  || key.indexOf('kplzts') > -1 || key.indexOf('lbtt') > -1){							
							localStorage.removeItem(key);	
							p++;
						}	
					}
					n = p - q;					
				}
				alert('清除完成');
			}
			
			function updateb(ss) {
				//alert(ss)	
				var dm = ss; 			 				
				var url4 = "https://apphq.longhuvip.com/w1/api/index.php?a=GetBaseFaceListZDEvnArtNew&apiv=w26&c=ZhiShuL2Data&StockID=" + dm;				
				var url5 = "https://apphis.longhuvip.com/w1/api/index.php?a=GetDayBaseFaceListZDEvnArt&st=10&c=ZhiShuKLine&apiv=w26&StockID=" + dm; 								
				
				xmlHttp4 = new XMLHttpRequest();								
				xmlHttp4.onreadystatechange = writeSource4;				
				xmlHttp4.open("GET", url4, true);
				xmlHttp4.send(null);
								
				xmlHttp5 = new XMLHttpRequest();								
				xmlHttp5.onreadystatechange = writeSource4;				
				xmlHttp5.open("GET", url5, true);
				xmlHttp5.send(null);								
			}
			
			function writeSource4() { 			
				if (xmlHttp4.readyState == 4 && xmlHttp5.readyState == 4) {                  	
					var data = xmlHttp4.responseText
					data = '{"List":[' + data + ']}';
					//document.write(data);						
					var div1 = document.getElementById('bar');												
					var fh = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='showInform(\"" + ztgp + "\")'>【返回】</a>";			
					div1.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rqb + "&nbsp;&nbsp;" + bkb + fh + "</b>";
																						
					var div = document.getElementById("content");						
					
					if(data.indexOf('"Date":""') == -1){
						var rq = data.match(/\"Date\":\"(\S*)\",\"/)[1];						
						var day = new Date();
						gt = day.getTime();			
						mymonth = day.getMonth()+1;
						myday = day.getDate();
						if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
						if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
						tt = day.getFullYear() + "-" + mymonth + "-" + myday;													
						if(rq == tt){
							var transform_aa = [           
							{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
							];
							
							var transform_bb= 
							{"tag":"p", children:[
							{"tag":"li", children:[							
							{"tag": "p style=color:#FFFF00;", "html":"${Date}：${BoomReason}"},
							{"tag": "p style=margin-top:-5px;color:#FFA500;", "html":"${Title}"}, 								
							]}]}; 
							
							var html = json2html.transform(data, transform_aa);																						
							div.innerHTML = html;
						}
					}
					
					var data1 = xmlHttp5.responseText
					if(data1.indexOf('\"List\":[]') == -1){
						var transform_aa = [           
						{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
						];
						
						var transform_bb= 
						{"tag":"p", children:[
						{"tag":"li", children:[							
						{"tag": "p style=color:#E1FFFF;", "html":"${Date}：${BoomReason}"},
						{"tag": "p style=margin-top:-5px;color:#FFA500;", "html":"${Title}"}, 								
						]}]}; 
						
						var html = json2html.transform(data1, transform_aa);					
						div.innerHTML = html;
					}else if(data1.indexOf('\"List\":[]') > -1 && data.indexOf('"Date":""') > -1){						
						div.innerHTML = "暂无数据";	
					}
					div.style.whiteSpace = "normal";  //折行
					div.style.fontSize="14px";						
				}					
			}
			
			var datahq = "";
			var lbt = "";
			function lbtt(){  //连板天梯
				var lbs = "";
				var ts = tz.split(";");	
				lbt = ts[0];				
				for (i = 0; i < 10; i++){
					//alert(ts[i])
					datahq = "";					
					if(i == 0 && dt == ts[0]){   //当日为最新交易日
						for (j = 0; j < 5; j++){
							getdata(5 - j, dt);					
						}
						datahq = datahq.replace(/\}\]\[\{/g,"},{");
					}else{
						if(localStorage.getItem('lbtt' + ts[i]) != null) {   //判断有无缓存数据														
							datahq = localStorage.getItem('lbtt' + ts[i]);    //取缓存数据	
							//alert(datahq)
						}else{
							for (j = 0; j < 5; j++){
								getdata(5 - j, ts[i]);;					
							}							
							datahq = datahq.replace(/\}\]\[\{/g,"},{");							
							localStorage.setItem('lbtt' + ts[i], datahq);  //历史单日数据写入缓存							
						}
					}
					//alert(datahq)
					var data = "";
					var lbd = "";
					if(datahq != ""){						
						var ss = datahq.split("},{");
						for (i1 = 0; i1 < ss.length; i1++){
							var lb = ss[i1].match(/"lb":"(\S*)","ztyy"/)[1];
							lb = UnUnicode(lb);
							if(lb.indexOf("天") > -1){
								lb = lb.split('天')[1];
							}
							lb = lb.replace("连板","").replace("板","");
							if(i1 == 0){
								lbd = lb;
							}
							<!-- if(lb == lbd){ -->
							if(lb == lbd || (z == 1 ? lb > 2 : 0)){
								data += ss[i1] + "},{";							
							}else{
								break;
							}							
						}
					}
					lbs += '["' + ts[i] + '",' + lbd.replace("连板","") + '],';
					//alert(lbs)
					data = '{"data":' + data + "]}";
					data = data.replace("},{]}","}]}");
					//alert(data)
					var transform_aa = [           
					{"tag":"p", children:function(){return(json2html.transform(this.data, transform_bb));}}
					];
					
					var transform_bb= 
					{"tag":"p", children:[												
					{"tag": "p", "html":"<a id='${code}' style='margin-left:-10px;color:#FFFACD;' href='http://www.treeid/code_${code}' onclick='changeCssa(this);showInform1(\"" + ts[i] + "\",\"${code}\");'>${name}(${lb})</a>"}, 
					]}; 
										
					var html = json2html.transform(data, transform_aa);		
				
					var div = document.getElementById("towritet" + (i+1));	
					div.innerHTML = html.replace(/连/g,'');	
					//Ctable1(data, "towritet" + (i+1));
				}
				lbs = "[" + lbs + "]";
				lbs = lbs.replace("],]","]]");	
				//alert(lbs)
				var json = JSON.parse(lbs);				
				//$("#chartst").text(dm + ' ' + mc);						
				goChart(json,"charts3","最高板");				
			}
			
			function changeCssa(obj){				
				var alist = document.getElementById("towritets").getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){									
					alist[i].style.color = "#FFFACD"; //给所有a标签赋原色
					if(alist[i].id == obj.id){
						alist[i].style.color = "#FF7F50";
					}
				}				
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			function getdata(i, rq) {
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w21&Type=4&c=HomeDingPan&PidType=" + i; 								
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + i + "&Day=" + rq;
				
				var url = url1;
				if(k == "1" || dt != rq){
					url = url2;					
				}
				if (window.XMLHttpRequest) {
					xmlHttp = new XMLHttpRequest();					
					} else {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");					
				}				
				xmlHttp.open("GET", url, false);  //同步方式
				xmlHttp.send(null);				
			    
				var data = xmlHttp.responseText
				data = data.replace("\[\[\]","\[\]");				
				//document.write(data);				
				if (data.indexOf('\"' + 'info' + '\"' + ':\[\]') == -1 ) { 
					data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';												
					data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					var lbs = str.split(',')[18];
					if(i < 5){
						lbs = '"' + i + '连板"';
					}
					if(i == 1){
						lbs = '"1板"';
					}
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"fde":'+str.split(',')[6] +
					',"lb":'+ lbs + 
					',"ztyy":'+str.split(',')[5];
					});
					data = data.replace(/\[\[\{/g,'[{').replace(/\]\]/g,"}]}").replace(/],{/g,"},{");
					
					//封单额				
					data = data.replace(/(\"fde\":).*?(?=,)/g, function(word){ 						
					str = word.match(/\"fde\":(\S*)/)[1]; 					
							if(keepTwoDecimal(Math.abs(str/100000000)) >= 1){
								return '\"fde\":\"' + keepTwoDecimal(str/100000000) + '亿\"';
							}else{
								return '\"fde\":\"' + Math.round(str/10000) + '万\"';
							}					
					});
					datahq += data.match(/\{\"info\":(\S*)\}\]\}/)[1] + "}]";
				}else{
					datahq += "";
				}										
			}					
			
			function showInform1(rq, dm){
				var div = document.getElementById('bar1');
				div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>连板&nbsp;&nbsp;&nbsp;" + rq + "</b>";
				
				var data = "";
				datahq = "";
				if(dt == rq){   //当日为最新交易日
					for (j = 0; j < 5; j++){
						getdata(5 - j, dt);					
					}
					data = datahq.replace(/\}\]\[\{/g,"},{");
				}else{
					if(localStorage.getItem('lbtt' + rq) != null) {   //判断有无缓存数据														
						data = localStorage.getItem('lbtt' + rq);    //取缓存数据	
						//alert(datahq)
					}
				}
				//document.write(data);
				Ctable1(data);
								
				var tlist = document.getElementById("towritelb").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 
					if(tlist[i].id == dm){
						tlist[i].style.backgroundColor = "#483D8B";
					}
				}			
			}
			
			function Ctable1(ss){
			//alert(ss)
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
																				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('fde','封单额').replace('lb','连板').replace('ztyy','涨停原因');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);	
					//th.style.color = "#E1FFFF";
					if(key == "连板"){												
						th.style.color = "#FFA500";							
					}
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;
						}else if(p == 2){  //名称列
							mc = rc;								
						}	
						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' style='float:left;'  onclick='changeCss1(this,\"" + dm + "\")'>" + rc + "</a>";																										
						//td.getElementsByTagName("a")[0].style.color = "#E1FFFF";
						if(p == 4){														
							td.getElementsByTagName("a")[0].style.color = "#FFA500";
						}					
						tr.appendChild(td);							
						p++;
					}																																	
					tbody.appendChild(tr);						
						
				}
				var div = document.getElementById("content1");
				div.innerHTML = "";		
				div.appendChild(table);
				//table.id = id;
				//changeTable1(table);		//隐藏某列	
				makeSortable1(table)
				hover1();				
			}
			
			//隐藏某列				
            function changeTable1(table) {
                var trs = table.rows;
                for (var i = 0, len = trs.length; i < len; i++) {
                    var cell = trs[i].cells[0]; //隐藏第1列					
                    cell.style.display = 'none';
                }
            }
			
			var pid1 = "";
			function changeCss1(obj, dm){				
				var tlist = document.getElementById("towritelb").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 
					if(tlist[i].id == dm){
						tlist[i].style.backgroundColor = "#483D8B";
					}
				}									
				pid1 = dm;	

				var alist = document.getElementById("towritets").getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){									
					alist[i].style.color = "#FFFACD"; //给所有a标签赋原色
					if(alist[i].id == dm){
						alist[i].style.color = "#FF7F50";
					}
				}		
			}
			
			function makeSortable1(table) {			
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
													
							showCol1(table,n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("连板") != -1 || headtxt.indexOf("涨停原因") != -1){
									val1 = val1;
									val2 = val2;
								}else{											
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol1(table,iCol){			
				var oTable = table;
				var id = oTable.id;
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = thcolor;
						oTable.rows[i].cells[3].style.color = "#FFA500";					
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}
				
				var otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = tdcolor;
					if(otagsA[i].id == 4){
						otagsA[i].style.color = "#FFA500";
					}						
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}				
			}
			
			function hover1(){  //鼠标经过			
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头							
							if(pid1.indexOf(this.id) == -1){  //过滤选中行
								this.style.background = bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}
		</script>
		
		
	<script>
		function goChart(dataArr,id,ss){                   
            var canvas,ctx;            
            var cWidth, cHeight, cMargin, cSpace;
            var originX, originY;            
            var tobalDots, dotSpace, maxValue;
            var totalYNomber;           
            var ctr, numctr, speed;
        
            // 获得canvas上下文
            canvas = document.getElementById(id);
            if(canvas && canvas.getContext){
                ctx = canvas.getContext("2d");
            }
            initChart(); // 图表初始化
            drawLineLabelMarkers(); // 绘制图表轴、标签和标记
            drawLineAnimate(); // 绘制折线图的动画
        
            // 图表初始化
            function initChart(){
                // 图表信息
                cMargin = 50;  //左边距
                cSpace = 40;   //下边距
                
                //canvas.width = Math.floor( (window.innerWidth-100)/2 ) * 3 ;
				var obj = document.getElementById("towritea");	
				canvas.width = Math.floor( (obj.clientWidth-100)/2 ) * 3 ;		//图表宽度									
                canvas.height = 300;	//图表高度				
                canvas.style.height = canvas.height/2 + "px";
                canvas.style.width = canvas.width/2 + "px";
                cHeight = canvas.height - cMargin - cSpace; //X轴间距
                cWidth = canvas.width - cMargin - cSpace;  //X轴间距
                originX = cMargin + cSpace;
                originY = cMargin + cHeight;
       
                // 折线图信息
                tobalDots = dataArr.length;
                dotSpace = parseInt( cWidth/tobalDots );
                maxValue = 0;
                for(var i=0; i<dataArr.length; i++){
                    var dotVal = parseInt( dataArr[i][1] );
                    if( dotVal > maxValue ){
                        maxValue = dotVal;
                    }
                }
                maxValue += 3;   //Y轴最大刻度值（倍数）
                totalYNomber = 5;  //Y轴刻度数量
                // 运动相关
                ctr = 1;
                numctr = 100;
                speed = 6;
        
                ctx.translate(0.5,0.5);  // 当只绘制1像素的线的时候，坐标点需要偏移，这样才能画出1像素实线
            }
        
            // 绘制图表轴、标签和标记
            function drawLineLabelMarkers(){
                ctx.font = "26px Arial";
                ctx.lineWidth = 2;
                ctx.fillStyle = "#E5E5E5";
                ctx.strokeStyle = "#E5E5E5";
                // y轴
                //drawLine(originX, originY, originX, cMargin);
                // x轴
                drawLine(originX, originY, originX+cWidth-100, originY);
        
                // 绘制标记
                drawMarkers();
            }
        
            // 画线的方法
            function drawLine(x, y, X, Y){
                ctx.beginPath();
                ctx.moveTo(x, y);
                ctx.lineTo(X, Y);
                ctx.stroke();
                ctx.closePath();
            }
        
            // 绘制标记
            function drawMarkers(){
                ctx.strokeStyle = "#E0E0E0";
                // 绘制 y 轴 及中间横线
                var oneVal = parseInt(maxValue/totalYNomber);
                ctx.textAlign = "right";
                for(var i=0; i<=totalYNomber; i++){
                    var markerVal =  i*oneVal;
                    var xMarker = originX-5;
                    var yMarker = parseInt( cHeight*(1-markerVal/maxValue) ) + cMargin;
                    
                    //ctx.fillText(markerVal, xMarker, yMarker+3, 20); // 文字
                    if(i>0){
                        //drawLine(originX+2, yMarker, originX+cWidth, yMarker); //Y轴刻度横线
                    }
                }
                // 绘制 x 轴 及中间竖线
                ctx.textAlign = "center";
                for(var i=0; i<tobalDots; i++){
                    var markerVal = dataArr[i][0];
                    var xMarker = originX+i*dotSpace;                    
					var yMarker = originY + 30;					
                    ctx.fillText(markerVal, xMarker, yMarker, 100); // 文字					
                    if(i>0){
                        //drawLine(xMarker, originY-2, xMarker, cMargin);  //X轴刻度竖线
                    }
                }
                // 绘制标题 y
                ctx.save();
                ctx.rotate(-Math.PI/2);
                //ctx.fillText("涨停数量", -canvas.height/2, cSpace-10);
                ctx.restore();
                // 绘制标题 x
                //ctx.fillText("月份", originX+cWidth/2, originY+cSpace/2+20);
				//alert(originY)
				ctx.fillText(ss, originX+cWidth/2, 80);
            };
        
            //绘制折线图
            function drawLineAnimate(){
                ctx.strokeStyle = "#566a80";  //"#49FE79";
        
                //连线
                ctx.beginPath();
                for(var i=0; i<tobalDots; i++){
                    var dotVal = dataArr[i][1];
                    var barH = parseInt( cHeight*dotVal/maxValue* ctr/numctr );//
                    var y = originY - barH;
                    var x = originX + dotSpace*i;
                    if(i==0){
                        ctx.moveTo( x, y );
                    }else{
                        ctx.lineTo( x, y );
                    }
                }
                ctx.stroke();
        
                //背景
                ctx.lineTo( originX+dotSpace*(tobalDots-1), originY);
                ctx.lineTo( originX, originY);
                //背景渐变色
                //柱状图渐变色
                var gradient = ctx.createLinearGradient(0, 0, 0, 300);
                gradient.addColorStop(0, 'rgba(133,171,212,0.6)');
                gradient.addColorStop(1, 'rgba(133,171,212,0.1)');
                ctx.fillStyle = gradient;
                ctx.fill();
                ctx.closePath();
                ctx.fillStyle = "#E5E5E5";
        
                //绘制点
                for(var i=0; i<tobalDots; i++){
                    var dotVal = dataArr[i][1];
                    var barH = parseInt( cHeight*dotVal/maxValue * ctr/numctr );
                    var y = originY - barH;
                    var x = originX + dotSpace*i;
                    drawArc( x, y );  //绘制点
                    ctx.fillText(parseInt(dotVal*ctr/numctr), x+15, y-8); // 文字					
                }
        
                if(ctr<numctr){
                    ctr++;
					<!-- ctx.clearRect(0,0,canvas.width, canvas.height); -->
					<!-- drawLineLabelMarkers(); -->
					<!-- drawLineAnimate(); -->
                    setTimeout(function(){   //折线动图效果
                        ctx.clearRect(0,0,canvas.width, canvas.height);
                        drawLineLabelMarkers();
                        drawLineAnimate();
                    }, speed);
                }
            }
        
            //绘制圆点
            function drawArc( x, y, X, Y ){
                ctx.beginPath();
                ctx.arc( x, y, 3, 0, Math.PI*2 );
                ctx.fill();
                ctx.closePath();
            }    
        }        
	</script>
	
	</body>
</html>